#
# @lc app=leetcode.cn id=763 lang=python
#
# [763] 划分字母区间
#

# @lc code=start
from collections import defaultdict
class Solution(object):
    def partitionLabels(self, s):
        """
        :type s: str
        :rtype: List[int]
        """
        sdict = defaultdict(int)
        for i, value in enumerate(s):
            sdict[value] = i
        start = 0
        end = 0
        result = []
        for i, value in enumerate(s):
            end = max(end, sdict[value])
            if i == end:
                result.append(end-start+1)
                start = i+1
        return result

        
# @lc code=end

